package ca.ericslandry.client.mvp.view;

import ca.ericslandry.client.mvp.presenter.ContentPresenter;

import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;

public class ContentView extends BaseView implements ContentPresenter.Display {
	private SimplePanel panel = new SimplePanel();
	private Widget prev;

	@Override
	public Widget asWidget() {
		return panel;
	}

	@Override
	public void setContent(Widget widget) {
		prev = panel.getWidget();
		panel.clear();
		panel.add(widget);
	}

	@Override
	public void pop() {
		if (prev != null) {
			setContent(prev);
		}
	}
}